Open
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
vite/src/views/products/plan/components/edit-plan-feature/EditPlanFeatureSheet.tsx
Show resolved
Hide resolved
vite/src/views/products/plan/components/edit-plan-feature/EditPlanFeatureSheet.tsx
Show resolved
Hide resolved
Contributor
Author
|
@cubic-dev-ai review |
Contributor
@charlietlamb I have started the AI code review. It will take a few minutes to complete. |
Contributor
There was a problem hiding this comment.
1 issue found across 8 files
Confidence score: 3/5
- There is a concrete regression risk in
vite/src/views/products/plan/components/edit-plan-feature/EditPlanFeatureSheet.tsx: volume pricing mode inference treatsflat_amount: 0as falsy, so valid zero-value flat pricing may initialize to the wrong mode. - Given the issue’s high severity/confidence (7/10, 9/10) and direct user-facing behavior impact in pricing setup, this carries moderate merge risk until corrected.
- Pay close attention to
vite/src/views/products/plan/components/edit-plan-feature/EditPlanFeatureSheet.tsx- mode inference logic should recognize zero flat amounts as valid flat mode inputs.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="vite/src/views/products/plan/components/edit-plan-feature/EditPlanFeatureSheet.tsx">
<violation number="1" location="vite/src/views/products/plan/components/edit-plan-feature/EditPlanFeatureSheet.tsx:46">
P1: Volume pricing mode inference is incorrect for valid zero flat amounts; `flat_amount: 0` should still initialize flat mode.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
vite/src/views/products/plan/components/edit-plan-feature/EditPlanFeatureSheet.tsx
Outdated
Show resolved
Hide resolved
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
Contributor
Author
|
@cubic-dev-ai review |
Contributor
@charlietlamb I have started the AI code review. It will take a few minutes to complete. |
Contributor
There was a problem hiding this comment.
1 issue found across 8 files
Confidence score: 2/5
- There is a high-confidence race condition in
vite/src/views/products/plan/components/edit-plan-feature/SheetFooterActions.tsx:onBeforeCommitis called withoutawait, so cleanup can overlap withhandleUpdateProductItemand commit stale item data. - Because this affects commit ordering in a save/update flow, the user-facing regression risk is significant until the async sequencing is fixed.
- Pay close attention to
vite/src/views/products/plan/components/edit-plan-feature/SheetFooterActions.tsx- ensure pre-commit work is awaited before updating or committing product item state.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="vite/src/views/products/plan/components/edit-plan-feature/SheetFooterActions.tsx">
<violation number="1" location="vite/src/views/products/plan/components/edit-plan-feature/SheetFooterActions.tsx:24">
P1: `onBeforeCommit` is invoked without awaiting completion, so pre-commit cleanup can race with `handleUpdateProductItem` and commit stale item data.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
vite/src/views/products/plan/components/edit-plan-feature/SheetFooterActions.tsx
Outdated
Show resolved
Hide resolved
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Greptile Summary
This PR adds a volume flat amount UI for volume-based, multi-tier feature pricing. Users can now toggle between a per-unit (
amount) view and a flat amount (flat_amount) view via a new segmented control that appears alongside the existing tier-behavior selector. The feature is backed by a newcleanTiersForModeutility that zeroes out unused fields before commit, and is well-covered by a new test file.Key changes:
Selectinto a newPriceSectionTitlecomponent and adds aPer Unit/Flat AmountIconCheckboxtoggle that is only shown for volume-based, multi-tier items.PriceTiersto accept avolumePricingModeprop, switching the editable field betweenamountandflat_amountand hiding theBillingUnitslabel in flat mode.cleanTiersForModeutility intierUtils.tsand ahandleBeforeCommithook inEditPlanFeatureSheetto ensure stale field values are zeroed/nulled before the item is committed.onBeforeCommitcallback toSheetFooterActionsthat is invoked synchronously beforehandleUpdateProductItem, preserving the existing commit flow.cleanTiersForModeandupdateTier(flat_amount path) intierUtils.test.ts.Two critical issues in
EditPlanFeatureSheetshould be addressed before merging:Stale
flat_amountwhen reducing tiers to one in flat mode — If a user edits a multi-tier volume-based item in flat mode and then removes tiers down to one, thehandleBeforeCommitguard condition skips cleanup. The single-tier item is submitted with leftoverflat_amountvalues that contradict the per-unit UI state shown to the user.volumePricingModestate doesn't reset when switching items — TheuseStatelazy initializer runs only once per mount. If users edit item A (with flat pricing) then switch to item B (without flat pricing) without closing the sheet, the toggle state remains frozen at item A's value, causing incorrect UI state for item B.Confidence Score: 2/5
cleanTiersForMode,updateTier) is correct and well-tested. UI components are cleanly structured. However,EditPlanFeatureSheethas two critical bugs: (1)handleBeforeCommitskips cleanup when users reduce a multi-tier volume item to single-tier in flat mode, leaving staleflat_amountin the submitted data; (2)volumePricingModestate won't reset when switching between items without remounting, causing incorrect toggle state. Both bugs lead to silent data corruption and should be fixed before shipping.Sequence Diagram
sequenceDiagram participant User participant PriceSectionTitle participant EditPlanFeatureSheet participant PriceTiers participant SheetFooterActions participant tierUtils User->>PriceSectionTitle: Select "Volume-based" tier behavior PriceSectionTitle->>EditPlanFeatureSheet: onTierBehaviorChange("VolumeBased") EditPlanFeatureSheet->>EditPlanFeatureSheet: setItem({ tier_behavior: VolumeBased }) Note over EditPlanFeatureSheet: showVolumePricingToggle = true<br/>(isVolumeBased && isMultiTier) User->>PriceSectionTitle: Click "Flat Amount" toggle PriceSectionTitle->>EditPlanFeatureSheet: onVolumePricingModeChange("flat") EditPlanFeatureSheet->>EditPlanFeatureSheet: setVolumePricingMode("flat") EditPlanFeatureSheet->>PriceTiers: volumePricingMode="flat" PriceTiers->>User: Shows flat_amount field (hides BillingUnits) User->>PriceTiers: Enter flat amount value PriceTiers->>tierUtils: updateTier({ field: "flat_amount", value }) tierUtils->>EditPlanFeatureSheet: setItem(updatedItem) User->>SheetFooterActions: Click "Update Plan Feature" SheetFooterActions->>EditPlanFeatureSheet: onBeforeCommit() EditPlanFeatureSheet->>tierUtils: cleanTiersForMode({ item, mode: "flat" }) tierUtils-->>EditPlanFeatureSheet: cleaned item (amount=0 preserved) EditPlanFeatureSheet->>EditPlanFeatureSheet: setItem(cleaned) SheetFooterActions->>SheetFooterActions: handleUpdateProductItem() Note over SheetFooterActions: commitItemDraft() or closeSheet() User->>PriceSectionTitle: Select "Graduated" tier behavior PriceSectionTitle->>EditPlanFeatureSheet: onTierBehaviorChange("Graduated") EditPlanFeatureSheet->>EditPlanFeatureSheet: setVolumePricingMode("per_unit") EditPlanFeatureSheet->>EditPlanFeatureSheet: clear flat_amount on all tiers EditPlanFeatureSheet->>EditPlanFeatureSheet: setItem(newItem)Last reviewed commit: c62fc87
Context used:
dashboard- CLAUDE.md (source)